import numpy as np
import random
t1 = np.array([1,2,3])
print(t1)
print(type(t1))

t2 = np.array(range(10))
print(t2)
print(type(t2))

# 将array与range合并
t3 = np.arange(10)
print(t3)
print(type(t3))

# int64类型,针对64位电脑
print(t3.dtype)

t4 = np.array(range(1,4),dtype=float)
print(t4.dtype)

t5 = np.array([1,1,0],dtype=bool)
print(t5.dtype)
print(t5)

#todo 调整数据类型
t6 = t5.astype('int8')
print(t6)
print(t6.dtype)
print(t5)
print(t5.dtype)

# numpy中的小数
t7 = np.array([random.random() for i in range(10)])
print(t7)
print(t7.dtype)
#todo 取小数
t8 = np.round(t7,2)
print(t8)